import _axios from 'axios'
import config from '@/config'
import axios from '@/libs/api.request'

const baseUrl = process.env.NODE_ENV === 'development' ?
    config.baseUrl.dev :
    config.baseUrl.pro
const authUrl = baseUrl + config.baseUrl.defaultPrefix

/**
 *
 * @param {*} param0
 */
export const login = ({ phone, captcha }) => {
    return _axios.get(authUrl + 'oauth/getjwt' + '?phone=' + phone + '&code=' + captcha)
}

/**
 *
 * @param {*} token
 */
export const getUserInfo = (token) => {
    return axios.request({
        method: 'get',
        withPrefix: false,
        url: 'account/profile',
        prefix: 'api/v1/'
    })
}

/**
 *
 * @param {*} token
 */
export const logout = (token) => {
    return new Promise((resolve, reject) => {
        resolve()
    })
}